﻿using System.Net;
using System.Text.Json;

namespace MYData.WebApi.Exceptionfilter
{
    /// <summary>
    /// 返回全局异常处理类
    /// </summary>  
    public class ErrorResponse
    {
        /// <summary>
        /// 返回状态码默认为500(内部服务器错误)
        /// </summary>
        public HttpStatusCode StatusCode { get; set; } = HttpStatusCode.InternalServerError;
        /// <summary>
        /// 异常信息
        /// </summary>
        public string Message { get; set; } = "An unexpected error occurred.";
        /// <summary>
        /// 将当前的异常Json序列化返回给客户端
        /// </summary>
        /// <returns></returns>
        public string ToJsonString() => JsonSerializer.Serialize(this);
    }
}
